package cn.edu.zafu.bigdata.Yum;

public class GetElementDemo {
    public static int getElement(int[] arr,int index){
        if(index>=arr.length){
            throw new ArrayIndexOutOfBoundsException("数组越界，索引超过数组范围！");
        }
        return arr[index];
    }

    public static void main(String[] args) {
        try{
            int[] arr={11,23,5,6,8,57,92,34,47,0};
            int index=100;
            int t=getElement(arr,index);
            System.out.println("arr数组中下标为"+index+"的元素是"+t);
        }catch(ArrayIndexOutOfBoundsException err){
            System.out.println("报错："+err.getMessage());
        }
    }
}
